//
//  DataHandle.m
//  On The Load
//
//  Created by 晓琳 on 15/11/7.
//  Copyright © 2015年 @@叶一闽. All rights reserved.
//

#import "DataHandle.h"
#import "HXLCityModel.h"

@implementation DataHandle


+(instancetype)shareDataHandle
{
    static DataHandle *handle = nil;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        handle = [DataHandle new];
    });
    [handle getPlace];

    return handle;
}


- (NSMutableDictionary *)getPlace {
    
    NSString *filepath = [[NSBundle mainBundle] pathForResource:@"city.plist" ofType:nil];
    NSMutableDictionary *bigDic = [NSMutableDictionary dictionaryWithContentsOfFile:filepath];
    
    self.finDic = [NSMutableDictionary dictionary];
    for (NSString *key in bigDic) {
        NSArray *bigArray = [bigDic objectForKey:key];

            NSMutableArray *cityArray = [NSMutableArray array];
            for (NSMutableDictionary *dic in bigArray) {
                
                HXLCityModel *model = [[HXLCityModel alloc] init];
                [model setValuesForKeysWithDictionary:dic];
                [cityArray addObject:model];
//                NSLog(@"model = = %@",model);
            }
        [self.finDic setObject:cityArray forKey:key];

    }
    
    
    return self.finDic;
}
@end
